
// 存储博客信息的表
var mongoose = require('./connect')

// 构建博客信息表需要存储的表结构
var blogSchema = new mongoose.Schema({
  title:String,
  tag:String,
  content:String,
  time:Number,
  // 因为用户信息的是从user表中获取的，所以此时进行表关联
  author:{
    type:mongoose.Schema.Types.ObjectId,
    ref:'user'
  },
  readNum:Number,
  reply: [
    {
      type:mongoose.Schema.Types.ObjectId,
      ref:'reply'
    }
  ]
})

// 映射一个表对象
var Blog = mongoose.model('blog',blogSchema)
module.exports = Blog

